package com.boot.security.server.common;

import io.swagger.annotations.ApiModelProperty;

/**
 * 返回结果
 *
 * @author: bruce.cheng
 */
public class Result<T> extends Base {

    /**
     * 结果对象(包含字段说明)
     */
    @ApiModelProperty(notes = "结果对象(包含字段说明)")
    private T model;

    /**
     * 是否请求成功，注：true=成功，false=失败，注意：如果 success=false 请参考：errorCode 错误码、errorMsg 错误信息、throwableMsg 系统抛出信息，进行分析调整
     */
    @ApiModelProperty(notes = "是否请求成功，注：true=成功，false=失败，注意：如果 success=false 请参考：errorCode 错误码、errorMsg 错误信息、throwableMsg 程序抛出信息，进行分析调整",allowableValues = "true,false",example = "true")
    private boolean success = true;

    /**
     * 错误码
     */
    @ApiModelProperty(notes = "错误码")
    private int errorCode;

    /**
     * 错误信息
     */
    @ApiModelProperty(notes = "错误信息")
    private String errorMsg;

    /**
     * 系统抛出信息
     */
    @ApiModelProperty(notes = "系统抛出信息")
    private String throwableMsg;

    /**
     * 构造函数
     *
     * @param
     * @return
     * @author bruce.cheng
     * @date 2019-01-24 14:01
     */
    public Result() {}

    /**
     * 构造函数
     *
     * @param success 成功状态
     * @param errorCode 错误码
     * @param errorMsg 错误信息
     * @return
     * @author bruce.cheng
     * @date 2019-01-24 14:02
     */
    public Result(boolean success, int errorCode, String errorMsg) {
        this.success = success;
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    /**
     * 构造函数
     *
     * @param success 成功状态
     * @param errorCode 错误码
     * @param errorMsg 错误信息
     * @param throwableMsg 系统抛出信息
     * @return
     * @author bruce.cheng
     * @date 2019-01-24 14:02
     */
    public Result(boolean success, int errorCode, String errorMsg, String throwableMsg) {
        this.success = success;
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.throwableMsg = throwableMsg;
    }


    public T getModel() {
        return model;
    }

    public void setModel(T model) {
        this.model = model;
    }

    public boolean getSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getThrowableMsg() {
        return throwableMsg;
    }

    public void setThrowableMsg(String throwableMsg) {
        this.throwableMsg = throwableMsg;
    }
}
